import {lazy } from "react";
import { Navigate } from "react-router-dom";
//权限组件
import Authority from "./Authority";

var Index = lazy(() => import('../views/Index/Index'))
var Login = lazy(() => import('../views/Login/Login'))
var NotFound = lazy(() => import('../views/NotFound/NotFound'))

var Home = lazy(() => import('../views/Index/Home/Home'))
var Account = lazy(() => import('../views/Index/Account/Account'))
var Banner = lazy(() => import('../views/Index/Banner/Banner'))
var BannerAdd = lazy(() => import('../views/Index/BannerAdd/BannerAdd'))
var Edit = lazy(() => import('../views/Index/Edit/Edit'))
var Excel = lazy(() => import('../views/Index/Excel/Excel'))
var Mapmanagement = lazy(() => import('../views/Index/Mapmanagement/Mapmanagement'))
var Pro = lazy(() => import('../views/Index/Pro/Pro'))
var Recommend = lazy(() => import('../views/Index/Pro/Recommend/Recommend'))
var Seckill = lazy(() => import('../views/Index/Pro/Seckill/Seckill'))
var Filter = lazy(() => import('../views/Index/Pro/Filter/Filter'))
var Statistic = lazy(() => import('../views/Index/Statistic/Statistic'))

//配置路由表
export default [
    {
        path: '/index',
        element: <Index />,
        children: [
            {
                path: '/index/home',
                element:<Authority permission='0'><Home /></Authority> ,
            },
            {
                path: '/index/banner',
                element: <Authority permission='1-1'><Banner /></Authority>,
            },
            {
                path: '/index/banneradd',
                element: <Authority permission='1'><BannerAdd /></Authority>,
            },
            {
                path: '/index/account',
                element:<Authority permission='2-1'><Account /></Authority>,
            },
            {
                path: '/index/pro',
                element: <Authority permission='3-1'><Pro /></Authority>,
            },
            {
                path: '/index/seckill',
                element: <Authority permission='3-2'><Seckill /></Authority>,
            },
            {
                path: '/index/recommend',
                element: <Authority permission='3-3'><Recommend /></Authority>,
            },
            {
                path: '/index/filter',
                element: <Authority permission='3-4'><Filter /></Authority>,
            },
            {
                path: '/index/statistic',
                element: <Authority permission='4-1'><Statistic /></Authority>,
            },
            {
                path: '/index/edit',
                element: <Authority permission='5-1'><Edit /></Authority>,
            },
            {
                path: '/index/excel',
                element: <Authority permission='6'><Excel /></Authority>,
            },
            {
                path: '/index/mapmanagement',
                element: <Authority permission='7-1'><Mapmanagement /></Authority>,
            },
            {
                path: '/index',
                element: <Navigate to="/index/home" />
            },
            {
                path: '*',
                element: <NotFound />
            },
        ]
    },
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/',
        element: <Navigate to="/index" />
    },
    {
        path: '*',
        element: <NotFound />
    },
]